ans = False
x22 = -105
y22 = -105
minx2 = 121
miny2 = 112
mxt = -105
maximusy = -105
mixxxx = 112
miniy = 121
maximusy= -105
y1, x1,y2,x2,y3,x3, y4,x4 = map(int, input().split())
x5,y5,x6,y6,x7,y7,x8,y8 = map(int, input().split())
ys = [x1,x2,x3,x4]
xs = [y1,y2,y3,y4]
for i in xs:
mxt = max(mxt,i)
mixxxx = min(mixxxx,i)
for i in ys:
maximusy = max(maximusy,i)
miniy = min(miniy,i)
xs = [x5,x6,x7,x8]
ys = [y5,y6,y7,y8]
for i in xs:
x22 = max(x22,i)
minx2 = min(minx2,i)
for i in ys:
y22 = max(y22,i)
miny2 = min(miny2,i)
mid = (x22-minx2)//2
cont = 0
for i in range(minx2, x22+1):
if(mid>0):
for j in range(miny2 + mid,y22 -mid + 1):
if i <= mxt and i >=mixxxx and j <= maximusy and j >= miniy:
ans = True
break
mid-=1
else:
for j in range(miny2 + cont, y22-cont+1):
if(i<= mxt and i>= mixxxx and j <= maximusy and j >= miniy):
ans = True
break
cont+=1
print('YES' if ans else 'NO')
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
vector< pair<double, double> >norm_square;
vector< pair<double, double> >rotate_square;
for (int i=0; i<4; i++) {
double x, y;
cin >> x >> y;
norm_square.push_back({x, y});
}
norm_square.push_back(norm_square[0]);
for (int i=0; i<4; i++) {
double x, y;
cin >> x >> y;
rotate_square.push_back({x, y});
}
rotate_square.push_back(rotate_square[0]);
bool flag = true;
for (auto p : rotate_square) {
double x, y;
x = p.first;
y = p.second;
for (int j=0; j<norm_square.size() - 1; j++) {
double x1 = norm_square[j].first, y1 = norm_square[j].second;
double x2 = norm_square[j + 1].first, y2 = norm_square[j + 1].second;
double A = y2 - y1;
double B = x1 - x2;
double C = x1 * (y1 - y2) + y1 * (x2 - x1);
double a = B;
double b = -A;
double c = -B * x + A * y;
// cout << A << " " << B << " " << C << "\n";
// cout << a << " " << b << " " << c << "\n";
double px, py;
C *= -1;
c *= -1;
if (a == 0) {
py = c / b;
px = (C - B * py) / A;
}
else if (A == 0) {
py = C / B;
// py = abs(py);
// cout << py << "\n";
px = (c - b * py) / a;
// cout << px << "\n";
}
else if (b == 0) {
px = c / a;
py = (C - A * px) / B;
}
else if (B == 0) {
px = C / A;
py = (c - a * px) / b;
}
else {
double k = (a / A);
py = (c - C * k) / (b - B * k);
px = (-b * py + c) / a;
}
// cout << px << " " << py << "\n";
// return 0;
if (min(x1, x2) <= px && px <= max(x1, x2)) {
if (min(y1, y2) <= py && py <= max(y1, y2)) {
// flag = true;
}
else {
// cout << A << " " << B << " " << C << "\n";
// cout << a << " " << b << " " << c << "\n";
// cout << x1 << " " << y1 << " " << x2 << " " << y2 << "\n";
// cout << x << " " << y << "\n";
// cout << px << " " << py << "\n";
// return 0;
flag = false;
// cout << j << "\n";
break;
}
}
else {
flag = false;
// cout << A << " " << B << " " << C << "\n";
// cout << a << " " << b << " " << c << "\n";
// cout << x1 << " " << y1 << " " << x2 << " " << y2 << "\n";
// cout << x << " " << y << "\n";
// cout << px << " " << py << "\n";
// return 0;
// cout << px << " " << py << "\n";
break;
}
}
}
if (flag) {
cout << "YES";
return 0;
}
flag = true;
for (auto p : norm_square) {
double x, y;
x = p.first;
y = p.second;
// bool flag = true;
for (int j=0; j<rotate_square.size() - 1; j++) {
double x1 = rotate_square[j].first, y1 = rotate_square[j].second;
double x2 = rotate_square[j + 1].first, y2 = rotate_square[j + 1].second;
double A = y2 - y1;
double B = x1 - x2;
double C = x1 * (y1 - y2) + y1 * (x2 - x1);
double a = B;
double b = -A;
double c = -B * x + A * y;
// cout << A << " " << B << " " << C << "\n";
// cout << a << " " << b << " " << c << "\n";
double px, py;
C *= -1;
c *= -1;
if (a == 0) {
py = c / b;
px = (C - B * py) / A;
}
else if (A == 0) {
py = C / B;
py = abs(py);
px = (c - b * py) / a;
// cout << px << "\n";
}
else if (b == 0) {
px = c / a;
py = (C - A * px) / B;
}
else if (B == 0) {
px = C / A;
py = (c - a * px) / b;
}
else {
double k = (a / A);
py = (c - C * k) / (b - B * k);
px = (-b * py + c) / a;
}
// cout << px << " " << py << "\n";
// return 0;
if (min(x1, x2) <= px && px <= max(x1, x2)) {
if (min(y1, y2) <= py && py <= max(y1, y2)) {
// flag = true;
}
else {
flag = false;
// cout << j << "\n";
break;
}
}
else {
flag = false;
// cout << px << " " << py << "\n";
break;
}
}
}
if (flag) {
// cout << x << " " << y << "\n";
cout << "YES";
return 0;
}
for (int i=0; i<rotate_square.size() - 1; i++) {
for (int j=0; j<norm_square.size() - 1; j++) {
double x1 = norm_square[j].first, y1 = norm_square[j].second;
double x2 = norm_square[j + 1].first, y2 = norm_square[j + 1].second;
double x3 = rotate_square[i].first, y3 = rotate_square[i].second;
double x4 = rotate_square[i + 1].first, y4 = rotate_square[i + 1].second;
double A = y2 - y1;
double B = x1 - x2;
double C = x1 * (y1 - y2) + y1 * (x2 - x1);
double a = y4 - y3;
double b = x3 - x4;
double c = x3 * (y3 - y4) + y3 * (x4 - x3);
// cout << A << " " << B << " " << C << "\n";
// cout << a << " " << b << " " << c << "\n";
double px, py;
C *= -1;
c *= -1;
if (a == 0) {
py = c / b;
px = (C - B * py) / A;
}
else if (A == 0) {
py = C / B;
py = abs(py);
px = (c - b * py) / a;
// cout << px << "\n";
}
else if (b == 0) {
px = c / a;
py = (C - A * px) / B;
}
else if (B == 0) {
px = C / A;
py = (c - a * px) / b;
}
else {
double k = (a / A);
py = (c - C * k) / (b - B * k);
px = (-b * py + c) / a;
}
// cout << px << " " << py << "\n";
if (min(x1, x2) <= px && px <= max(x1, x2)) {
if (min(y1, y2) <= py && py <= max(y1, y2)) {
if (min(x3, x4) <= px && px <= max(x3, x4)) {
if (min(y3, y4) <= py && py <= max(y3, y4)) {
// cout << x1 << " " << y1 << "--> " << x2 << " " << y2 << "\n";
// cout << x3 << " " << y3 << "--> " << x4 << " " << y4 << "\n";
cout << "YES";
return 0;
}
}
}
}
}
// return 0;
}
cout << "NO";
return 0;
}
1367B - Even Array | 136A - Presents |
1450A - Avoid Trygub | 327A - Flipping Game |
411A - Password Check | 1520C - Not Adjacent Matrix |
1538B - Friends and Candies | 580A - Kefa and First Steps |
1038B - Non-Coprime Partition | 43A - Football |
50A - Domino piling | 479A - Expression |
1480A - Yet Another String Game | 1216C - White Sheet |
1648A - Weird Sum | 427A - Police Recruits |
535A - Tavas and Nafas | 581A - Vasya the Hipster |
1537B - Bad Boy | 1406B - Maximum Product |
507B - Amr and Pins | 379A - New Year Candles |
1154A - Restoring Three Numbers | 750A - New Year and Hurry |
705A - Hulk | 492B - Vanya and Lanterns |
1374C - Move Brackets | 1476A - K-divisible Sum |
1333A - Little Artem | 432D - Prefixes and Suffixes |